Page({

  data:{
    searchInputStyle:"",
    searchStyle:"",
    menuScroll:false,
    menuList:[],
    selectedMenuId:0
  },

  onLoad(){
    this.getMenuPosition()
    this.getMenuList()
  },
  // 更改菜单选项
  chooseMenu(event){
    console.log(event)
    let id = event.currentTarget.dataset.id
    this.setData({
      selectedMenuId: id
    })
  },

  //获取胶囊的位置信息
  getMenuPosition(){
   let {height,top} = wx.getMenuButtonBoundingClientRect()
   //  输入框的高度
   let serchInputHeight = "height:"+height+"px"
   // 输入框的位置
   let searchTop = "margin-top:"+top+"px"

   this.setData({
     searchInputStyle:serchInputHeight,
     searchStyle:searchTop
   })
  },
  //获取菜单栏列表数据
  getMenuList(){
    wx.request({
      url: 'http://localhost:9527/imgs/1',
      method: "GET",
      success: res =>{
        console.log(res.data.data)
        this.setData({
          menuList: res.data.data,
          selectedMenuId: res.data.data[0].id
        })
      }
    })
  }

})